// 把类创建逻辑 和 单例模式分开。

function Window(name) {
    this.name = name;

}
Window.prototype.getName = function () {
    console.log(this.name)
}
function Dialog(title, content) {
    this.title = title;
    this.content = content;

}
//处理单例模式
let CreatSingle = (function (Constructor) {
    let instance;
    return function (name) {
        if (!instance) {
            Constructor.apply(this, arguments);
            // this._proto = constructor.prototype
            Object.setPrototypeOf(this, Constructor.prototype);
            instance = this;
        }
        return instance;
    }
}
)()

// 用法
let newObj = new CreatSingle(Window);
let w2 = new newObj("html");
let w1 = new newObj("jd");


console.log(w1 === w2)
